Beging the long, hard road of moving core structures from char * to QString.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Feb 2013 06:02:10 +0000 (06:02 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Feb 2013 06:02:10 +0000 (06:02 +0000)
Mostly, this just compartmentalizes the pain of character set conversions in
xmlgeneric.cc while letting them accpet QStrings.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4302 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/cet_util.cc
gpsbabel/cet_util.h
gpsbabel/defs.h
gpsbabel/garmin_txt.cc
gpsbabel/gbfile.cc
gpsbabel/gbfile.h
gpsbabel/gdb.cc
gpsbabel/xmlgeneric.cc
gpsbabel/xmlgeneric.h

index 3bdb49a45345002913c14411e27ab404490d91c2..54b0e0898e2d84ad236fb9fa30f0253ebefe92d7 100644 (file)
@@ -1020,6 +1020,11 @@ cet_convert_string(char* str)
   return res;
 }
 
+const char *
+cet_convert_string(QString str) {
+  return cet_convert_string(str.toUtf8().data());
+}
+
 /* cet_convert_waypt: internal used within cet_convert_strings process */
 
 static void
index abb5d3345ff17b86fa0ec4549a6bcfce762bc508..e01a73ef4af05ab5453fe86c7673f1431f127b4c 100644 (file)
@@ -109,6 +109,7 @@ int cet_gbfprintf(gbfile* stream, const cet_cs_vec_t* src_vec, const char* fmt,
 
 /* cet_convert_string: !!! ONLY VALID WITHIN 'cet_convert_strings' process !!! */
 char* cet_convert_string(char* str);
+const char* cet_convert_string(QString str);
 
 /* gpsbabel extensions */
 
index aa547669a7205d57ad44f71284579b9868a26847..5a1caf0990433560484e5080792562de9f022070 100644 (file)
@@ -375,7 +375,7 @@ class url_link {
     url(NULL),
     url_link_text(NULL)
      {} ;
-  struct url_link* url_next;
+  url_link* url_next;
   char* url;
   char* url_link_text;
 };
@@ -539,7 +539,7 @@ public:
    * We also use an implicit anonymous union here, so these three
    * members must match struct url_link...
    */
-  struct url_link* url_next;
+  url_link* url_next;
   char* url;
   char* url_link_text;
 
index 9c8ad1edc114c895f9f7657c48d0eeba6ebf9913..22a66d3b2054816fcf93dea45f15548e0063948c 100644 (file)
@@ -523,6 +523,12 @@ print_string(const char* fmt, const char* string)
   xfree(buff);
 }
 
+static void
+print_string(const char* fmt, const QString string)
+{
+  print_string(fmt, string.toUtf8().data());
+}
+
 
 /* main cb's */
 
index 376d2b2c83f3fc46cc0fe531bc712390479a64f5..e85d5622e7e3ee826c3d290ee7fca40ca9114292 100644 (file)
@@ -1226,6 +1226,11 @@ gbfputcstr(const char* s, gbfile* file)
     return 1;
   }
 }
+int
+gbfputcstr(const QString s, gbfile* file)
+{
+  return gbfputcstr(qPrintable(s), file);
+}
 
 /*
  * gbfputcstr: write a pascal string into a stream
index f4ed58e4181a40923ee5455c1dfec56bd2aacbb9..7b9a05b9c75bf21d25d923d620d6dd2fb7d31839 100644 (file)
@@ -130,6 +130,7 @@ int gbfputint32(const gbint32 i, gbfile* file);
 int gbfputdbl(const double d, gbfile* file);   // write a double value
 int gbfputflt(const float f, gbfile* file);    // write a float value
 int gbfputcstr(const char* s, gbfile* file);   // write string including '\0'
+int gbfputcstr(const QString s, gbfile* file); // write string including '\0'
 int gbfputpstr(const char* s, gbfile* file);   // write as pascal string
 
 gbsize_t gbfcopyfrom(gbfile* file, gbfile* src, gbsize_t count);
index 0e5d6af4e00f9065adc820c9fc5ddd97678cc735..2227f17059e46bf78760a85f010e4e9303554aae 100644 (file)
@@ -391,6 +391,12 @@ gdb_write_cstr_list(const char* str)
   }
 }
 
+static void
+gdb_write_cstr_list(const QString str)
+{
+  return gdb_write_cstr_list(str.toAscii().data());
+}
+
 static void
 gdb_write_dbl(const double value, const double def)
 {
index 70703097fee3d17eae1741eb87c8a37d0fec6b76..4c99ce3e8305f93b6a96ce2787e65b2f76ab7d51 100644 (file)
@@ -53,52 +53,52 @@ write_xml_header(gbfile *ofd)
 }
 
 void
-write_xml_entity(gbfile *ofd, const char *indent,
-                 const char *tag, const char *value)
+write_xml_entity(gbfile *ofd, QString indent,
+                 QString tag, QString value)
 {
-  char *tmp_ent = xml_entitize(value);
-  gbfprintf(ofd, "%s<%s>%s</%s>\n", indent, tag, tmp_ent, tag);
+  char *tmp_ent = xml_entitize(value.toAscii().data());
+  gbfprintf(ofd, "%s<%s>%s</%s>\n", qPrintable(indent), qPrintable(tag), tmp_ent, qPrintable(tag));
   xfree(tmp_ent);
 }
 
 void
-write_optional_xml_entity(gbfile *ofd, const char *indent,
-                          const char *tag, const char *value)
+write_optional_xml_entity(gbfile *ofd, const QString indent,
+                          const QString tag, const QString value)
 {
-  if (value && *value) {
+  if (!value.isEmpty()) {
     write_xml_entity(ofd, indent, tag, value);
   }
 }
 
 void
-write_xml_entity_begin0(gbfile *ofd, const char *indent,
-                        const char *tag)
+write_xml_entity_begin0(gbfile *ofd, const QString indent,
+                        const QString tag)
 {
-  gbfprintf(ofd, "%s<%s>\n", indent, tag);
+  gbfprintf(ofd, "%s<%s>\n", indent.toAscii().data(), tag.toAscii().data());
 }
 
 void
-write_xml_entity_begin1(gbfile *ofd, const char *indent,
-                        const char *tag, const char *attr,
-                        const char *attrval)
+write_xml_entity_begin1(gbfile *ofd, const QString indent,
+                        const QString tag, const QString attr,
+                        const QString attrval)
 {
-  gbfprintf(ofd, "%s<%s %s=\"%s\">\n", indent, tag, attr, attrval);
+  gbfprintf(ofd, "%s<%s %s=\"%s\">\n", indent.toAscii().data(), tag.toAscii().data(), attr.toAscii().data(), attrval.toAscii().data());
 }
 
 void
-write_xml_entity_begin2(gbfile *ofd, const char *indent,
-                        const char *tag, const char *attr1,
-                        const char *attrval1, const char *attr2,
-                        const char *attrval2)
+write_xml_entity_begin2(gbfile *ofd, const QString indent,
+                        const QString tag, const QString attr1,
+                        const QString attrval1, const QString attr2,
+                        const QString attrval2)
 {
-  gbfprintf(ofd, "%s<%s %s=\"%s\" %s=\"%s\">\n", indent, tag, attr1, attrval1, attr2, attrval2);
+  gbfprintf(ofd, "%s<%s %s=\"%s\" %s=\"%s\">\n", indent.toAscii().data(), tag.toAscii().data(), attr1.toAscii().data(), attrval1.toAscii().data(), attr2.toAscii().data(), attrval2.toAscii().data());
 }
 
 void
-write_xml_entity_end(gbfile *ofd, const char *indent,
-                     const char *tag)
+write_xml_entity_end(gbfile *ofd, const QString indent,
+                     const QString tag)
 {
-  gbfprintf(ofd, "%s</%s>\n", indent, tag);
+  gbfprintf(ofd, "%s</%s>\n", indent.toAscii().data(), tag.toAscii().data());
 }
 
 void
index 6252c6caec73aded4d195a23a4aed67dd27815f1..27e2b69ae51bc2dd3cb9af60eeb8b35bbc8947c7 100644 (file)
@@ -37,19 +37,20 @@ typedef struct xg_tag_mapping {
 
 extern char* xhtml_entities;
 
-void write_xml_entity(gbfile* ofd, const char* indent,
-                      const char* tag, const char* value);
-void write_xml_entity_begin0(gbfile* ofd, const char* indent,
-                             const char* tag);
-void write_xml_entity_begin1(gbfile* ofd, const char* indent, const char* tag,
-                             const char* attr1, const char* attrval1);
-void write_xml_entity_begin2(gbfile* ofd, const char* indent, const char* tag,
-                             const char* attr1, const char* attrval1,
-                             const char* attr2, const char* attrval2);
-void write_xml_entity_end(gbfile* ofd, const char* indent, const char* tag);
+void write_xml_entity(gbfile* ofd, const QString indent,
+                      const QString tag, const QString value);
+void write_xml_entity_begin0(gbfile* ofd, const QString indent,
+                             const QString tag);
+void write_xml_entity_begin1(gbfile* ofd, const QString indent, 
+                             const QString tag, const QString attr1, 
+                             const QString attrval1);
+void write_xml_entity_begin2(gbfile* ofd, const QString indent, const QString tag,
+                             const QString attr1, const QString attrval1,
+                             const QString attr2, const QString attrval2);
+void write_xml_entity_end(gbfile* ofd, const QString indent, const QString tag);
 
-void write_optional_xml_entity(gbfile* ofd, const char* indent,
-                               const char* tag, const char* value);
+void write_optional_xml_entity(gbfile* ofd, const QString ndent,
+                               const QString tag, const QString value);
 void xml_write_time(gbfile* ofd, const time_t timep, int microseconds, const char* elname);
 void xml_fill_in_time(char* time_string, const time_t timep, int microseconds,
                       int long_or_short);